{extend name="base" /}
{block name="body"}
<div class="layui-card">
    <div class="layui-card-body">
        <form action="" class="layui-form" method="post" onsubmit="return false;">
     

             <div class="layui-form-item">
                   <label class="layui-form-label">默认图片</label>
                 <div class="layui-input-inline">
                        <div class="profile-avatar-container">
                  <img id="image" class="profile-user-img img-responsive" src="{$img.url|default='/static/libs/images/no_image.jpg'}" alt="">
            <span class="layui-upload-list">
                   <div class="profile-avatar-text">{:__('Click Edit')}</div>
               <button type="button" id="ajax-admin-avatar"><i class="fa fa-upload"></i>{:__('Edit')}</button>
            </span>
            <span class="layui-upload-list" style="padding-left: 20px;"></span>
                       </div>
                   </div>
            <input type="hidden" name="filesize" id="filesize" value="">
            <input type="hidden" name="mine" id="mine" value="">
            <input type="hidden" name="image" value="">
           </div>
        <div class="layui-form-item">
            <label class="layui-form-label">{:__('Column')}</label>
            <div class="layui-input-inline" style="width:170px;">
                <select class="layui-input" name="cat_id" id="cat_id" style="width: 95%" lay-verify="required" lay-search="">
                    <option value="0">无</option>
                   {foreach $name as $vo} 
                    
                    <option value="{$vo.id}" {if condition="isset($list.cat_id) and $list.cat_id == $vo.id"}selected="selected"{/if}>{$vo.name}</option>             
                    {/foreach}
                </select>
            </div>
        </div>
        <div class="layui-form-item">
            <label class="layui-form-label">{:__('title')}</label>
            <div class="layui-input-block">
                <input type="text" name="title" id="title" value="{$list.title|default=''}" style="width: 95%" lay-verify="required"
                       placeholder="标题"
                       autocomplete="off" class="layui-input">
            </div>
        </div>

        <div class="layui-form-item">
            <label class="layui-form-label">{:__('content')}</label>
            <div class="layui-input-block">
                <textarea placeholder="请输入内容" lay-verify="required" name="content" style="width: 95%" id="content" class="layui-textarea">{$list.content|default=''}</textarea>
            </div>
        </div>

        <div class="layui-form-item">
            <label class="layui-form-label">{:__('sign')}</label>
            <div class="layui-input-block" style="width:170px;">                
                <select class="layui-input" name="flag" id="flag" lay-verify="required" lay-search="">    
                    <option value="0">{:__('Please select')}</option>                  
                <option value="1" {if isset($list.flag) and $list.flag == 1}selected{/if} title="{:__('newest')}" class="layui-input">{:__('newest')}</option>
                <option value="2" {if isset($list.flag) and $list.flag == '2'}selected{/if} title="{:__('Hot')}" class="layui-input">{:__('Hot')}</option>
                <option value="3" {if isset($list.flag) and $list.flag == '3'}selected{/if} title="{:__('recommend')}" class="layui-input">{:__('recommend')}</option>
                </select>
            </div>

            </div>    
        <div class="layui-form-item">
            <label class="layui-form-label">{:__('sort')}</label>
            <div class="layui-input-inline"> 
                <input type="radio" name="weigh" value="1" {if isset($list.weigh) and $list.weigh == 1}checked{/if} title="{:__('Top')}" class="layui-input">
                <input type="radio" name="weigh" value="0" {if isset($list.weigh) and $list.weigh == '0'}checked{/if} title="{:__('normal')}" class="layui-input">
            
            </div>
        </div>
            <div class="layui-form-item">
                <div class="layui-input-block">
                    <button class="layui-btn layui-btn-sm" lay-filter="save" lay-submit="">保存</button>
                    <button class="layui-btn layui-btn-sm layui-btn-danger close">关闭</button>
                </div>
            </div>
        </form>
    </div>
</div>
{/block}
{block name="js"}
<script>
layui.use(function(){
             var upload = layui.upload; // 上传
             var form = layui.form;
             var $ = layui.jquery; 
             form.render();
   //普通图片上传
      var uploadInst = upload.render({
    elem: '#ajax-admin-avatar',
            exts: 'jpg|png|jpeg|gif|svg',
            size: 2048,
    url: "{:url('upload/uploadImage',['model'=>'4'])}", //Change to your own upload interface //改成您自己的上传接口
    done: function (result) {
        // 上传完毕回调
        if (result.code === 1) {
            $('#image').attr('src', result.url);
            //this.item.prev('input').val(result.url);
            $('input[name="image"]').val(result.url);
            $('input[name="filesize"]').val(result.filesize);
            $('input[name="mine"]').val(result.mine);
            layer.msg(result.msg, {icon: 1});
        } else {
            layer.msg(result.msg, {icon: 2});
        }
    }
        });
});
</script>
{/block}


